{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "initial_id",
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2024-09-29T08:50:17.124568800Z",
     "start_time": "2024-09-29T08:50:17.099559300Z"
    }
   },
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0    1\n",
      "1    2\n",
      "2    3\n",
      "dtype: int64\n"
     ]
    }
   ],
   "source": [
    "# 传入列表或numpy数组初始化Series\n",
    "arr = [1, 2, 3]\n",
    "series1 = pd.Series(arr)\n",
    "print(series1)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-09-29T08:50:17.140573Z",
     "start_time": "2024-09-29T08:50:17.108559100Z"
    }
   },
   "id": "53ad7f053ea077d6"
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a    1\n",
      "b    2\n",
      "c    3\n",
      "dtype: int64\n"
     ]
    }
   ],
   "source": [
    "# 自定义索引\n",
    "arr = [1, 2, 3]\n",
    "index = ['a', 'b', 'c']\n",
    "series2 = pd.Series(arr, index=index)\n",
    "print(series2)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-09-29T08:50:17.140573Z",
     "start_time": "2024-09-29T08:50:17.119559700Z"
    }
   },
   "id": "6c67027ada55f6ca"
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "1\n"
     ]
    }
   ],
   "source": [
    "# 索引访问\n",
    "print(series1[0])\n",
    "print(series2['a'])"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-09-29T08:50:17.154639Z",
     "start_time": "2024-09-29T08:50:17.136561800Z"
    }
   },
   "id": "345bcbe8702abd63"
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "outputs": [],
   "source": [],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-09-29T08:50:17.197176700Z",
     "start_time": "2024-09-29T08:50:17.151182200Z"
    }
   },
   "id": "c9bd96e9c2cb55d"
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
